package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: wx
 * Date: 2023-12-06
 * Time: 23:28
 */
//
public class ThreadDemo8 {
    public static void main1(String[] args) {
        Thread t = new Thread(() ->{
            while(true){
                System.out.println("hello");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();

        //第二次调用 start ,就会出现问题
        //出现异常,"达拉崩吧" 名字长,是为了能够读清楚,异常为非法线程异常
        t.start();
    }

    public static void main(String[] args) {
        Thread t = new Thread(() ->{

                System.out.println("hello");

        });
        t.start();
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //第二次调用就会出现异常
        t.start();
    }
}
